package com.kgcx.push.utils;

import com.kgcx.common.utils.date.DateUtils;
import net.sf.json.JSON;
import net.sf.json.JSONObject;
import org.dom4j.*;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.StringWriter;
import java.util.*;

/**
 * @author 何凯
 * @version 0.1
 * @description
 * @time 2018/4/26 16:22
 * @since 0.1
 */
public class XmlUtils {

    public static void main(String[] args) throws DocumentException, IOException {
        // 存储十个表日志数据
        // dataSetMap以DATASET为key,dataSetList为value,表示<MESSAGE>标签下十个日志表的<DATASET>标签
        Map<String, Object> dataSetMap = new LinkedHashMap<>();
        List<Map<String, Object>> dataSetList = new ArrayList<>();

        //   顾客注册日志信息处理
        List<Map<String, Object>> customerLoglist = setCustomerList();
        // 将转换后的map添加到dataSetList中
        Map customerLogDataSet = mapToMapForCustomer(customerLoglist);
        dataSetList.add(customerLogDataSet);

        // 专车/顺风车/快车注册日志信息处理
        List<Map<String, Object>> driverLoglist = setDriverList();
        // 将转换后的map添加到dataSetList中
        Map driverLogDataSet = mapToMapForDriver1(driverLoglist);
        dataSetList.add(driverLogDataSet);

        // 出租车注册日志信息处理
        // 将转换后的map添加到dataSetList中
        Map driver2DataSet = mapToMapForDriver2();
        dataSetList.add(driver2DataSet);

        // 代驾注册日志信息处理
        // 将转换后的map添加到dataSetList中
        Map driver3DataSet = mapToMapForDriver3();
        dataSetList.add(driver3DataSet);

        // 登录日志信息处理
        List<Map<String, Object>> loginLoglist =setLoginList();
        // 将转换后的map添加到dataSetList中
        Map loginLogDataSet = mapToMapForLogin(loginLoglist);
        dataSetList.add(loginLogDataSet);

        // 订单日志信息处理
        List<Map<String, Object>> orderLoglist = setOrderList();
        // 将转换后的map添加到dataSetList中
        Map orderLogDataSet = mapToMapForOrder(orderLoglist);
        dataSetList.add(orderLogDataSet);

        // 结算日志信息处理
        List<Map<String, Object>> payLoglist =setPayList();
        // 将转换后的map添加到dataSetList中
        Map payLogDataSet = mapToMapForPay(payLoglist);
        dataSetList.add(payLogDataSet);

        // 行驶轨迹日志信息处理
        // 行驶轨迹日志DATASET中ITEM数据
        List<Map<String, Object>> positionLoglist = setPositionList();

        // 将转换后的map添加到dataSetList中
        Map positionLogDataSet = mapToMapForDriving(positionLoglist);
        dataSetList.add(positionLogDataSet);

        // 聊天日志
        Map imLogDataSet = mapToMapForIM();
        dataSetList.add(imLogDataSet);

        // 快递日志
        Map deliveryLogDataSet = mapToMapForDelivery();
        dataSetList.add(deliveryLogDataSet);


        // 插入十个日志表的数据
        dataSetMap.put("DATASET", dataSetList);
        // 格式化输出
        JSON json = JSONObject.fromObject(positionLogDataSet);
        System.out.println(json.toString(1));
        Document doc = map2xml(dataSetMap, "MESSAGE");
        String fileName="d://"+DateUtils.toMailDateDtPartString(new Date())+".xml";
        createXmlFile(fileName, doc);
        //map中含有根节点的键
        System.out.println(formatXml(doc));
    }

    /**
     * 1.设值客户注册信息
     * @return
     */
    public static List<Map<String, Object>> setCustomerList(){
        List<Map<String, Object>> customerList = null;
        /*for (int i =0;i<1;i++) {
            Map<String, Object> customerLogMap = new LinkedHashMap<>();
            customerLogMap.put("accountId", "27");
            customerLogMap.put("username", "18680319022");
            customerLogMap.put("accountType", "手机");
            customerLogMap.put("account", "18680319022");
            customerLogMap.put("telephone", "18680319022");
            customerLogMap.put("certifiType", "身份证");
            customerLogMap.put("certifiCode", "433930199008155555");
            customerLogMap.put("ip", "175.6.6.30");
            customerLogMap.put("port", "80");
            customerLogMap.put("mac", "EC:D0:9F:D1:35:D7");
            customerLogMap.put("imei", "865736033683247");
            customerLogMap.put("imsi", "460013047114124");
            customerLogMap.put("userPhoto", "http://image.hangkechina.com/e47685540880424da49ffb4affafe7ff");
            customerLogMap.put("payAccountType", "");
            customerLogMap.put("payAccount", "");
            customerLogMap.put("city", "长沙");
            customerLogMap.put("regisTime", DateUtils.getUTCTime());
            customerLogMap.put("lastTime", DateUtils.getUTCTime());
            customerList.add(customerLogMap);
        }*/
        return customerList;
    }

    /**
     * 2.设值驾驶员信息
     * @return
     */
    public static List<Map<String, Object>> setDriverList(){
        List<Map<String, Object>> driverList = new ArrayList<>();
        for (int i =0;i<1;i++) {
            Map<String, Object> driverLogMap = new LinkedHashMap<>();
            driverLogMap.put("accountId", "13");
            driverLogMap.put("username", "肖杰");
            driverLogMap.put("accountType", "手机");
            driverLogMap.put("account", "18674385982");
            driverLogMap.put("telephone", "18674385982");
            driverLogMap.put("certifiType", "身份证");
            driverLogMap.put("certifiCode", "43042619911010625X");
            driverLogMap.put("ip", "175.6.6.30");
            driverLogMap.put("port", "80");
            driverLogMap.put("mac", "EC:D0:9F:D1:35:D7");
            driverLogMap.put("imei", "865736033683247");
            driverLogMap.put("imsi", "460013047114124");
            driverLogMap.put("userPhoto", "http://image.hangkechina.com/e47685540880424da49ffb4affafe7ff");
            driverLogMap.put("payAccountType", "");
            driverLogMap.put("payAccount", "");
            driverLogMap.put("vehicleId", "12");
            driverLogMap.put("vehicleCode", "湘A19917");
            driverLogMap.put("operCertificate", "YY20180101");
            driverLogMap.put("carColor", "黑色");
            driverLogMap.put("carBrand", "大众");
            driverLogMap.put("carVersion", "帕萨特");
            driverLogMap.put("policyPhoto", "http://image.hangkechina.com/e47685540880424da49ffb4affafe7ff");
            driverLogMap.put("company", "空港出行");
            driverLogMap.put("city", "长沙");
            driverLogMap.put("regisTime", DateUtils.getUTCTime());
            driverLogMap.put("lastTime",  DateUtils.getUTCTime());
            driverList.add(driverLogMap);
        }
        return driverList;
    }

    /**
     * 3.设值登录日志
     * @return
     */
    public static List<Map<String, Object>> setLoginList(){
        List<Map<String, Object>> loginList = new ArrayList<>();
        for (int i =0;i<5;i++) {
            Map<String, Object> loginLogMap = new LinkedHashMap<>();
            loginLogMap.put("accountId", "27");
            loginLogMap.put("username", "18680319022");
            loginLogMap.put("srcIp", "175.6.6.30");
            loginLogMap.put("srcPort", "80");
            loginLogMap.put("mac", "EC:D0:9F:D1:35:D7");
            loginLogMap.put("imsi", "460013047114124");
            loginLogMap.put("imei", "865736033683247");
            loginLogMap.put("logType", "APP");
            loginLogMap.put("logTime",DateUtils.getUTCTime());
            loginLogMap.put("long", "112.931278");
            loginLogMap.put("lat", "28.235271");
            loginList.add(loginLogMap);
        }
        return loginList;
    }
    /**
     * 4.设值订单日志
     * @return
     */
    public static List<Map<String,Object>> setOrderList(){
        List<Map<String, Object>> orderList = new ArrayList<>();
        for (int i =0;i<10;i++) {
            Map<String, Object> orderLogMap = new LinkedHashMap<>();
            orderLogMap.put("accountId", "13017313120");
            orderLogMap.put("orderText", "乘客叫车");
            orderLogMap.put("orderMedia", "");
            orderLogMap.put("orderTime", "2018-05-07 19:05:44");
            orderLogMap.put("orderPhone", "13017313120");
            orderLogMap.put("orderPort", "80");
            orderLogMap.put("orderIp", "175.6.6.30");
            orderLogMap.put("orderMac", "EC:D0:9F:D1:35:D7");
            orderLogMap.put("orderImei", "865736033683247");
            orderLogMap.put("orderImsi", "460013047114124");
            orderLogMap.put("orderAdd", "长沙市岳麓区金星北路517号");
            orderLogMap.put("orderLong", "112.931278");
            orderLogMap.put("orderLat", "28.235271");
            orderLogMap.put("vehicleType", "专车");
            orderLogMap.put("aboardTime", "2018-05-07 19:05:44");
            orderLogMap.put("aboardAdd", "长沙市岳麓区金星北路517号");
            orderLogMap.put("aboardLong", "112.931278");
            orderLogMap.put("aboardLat", "28.235271");
            orderLogMap.put("debusAdd", "长沙市岳麓区中电软件园");
            orderLogMap.put("debusLong", "");
            orderLogMap.put("debusLat", "");
            orderLogMap.put("getCity", "");
            orderLogMap.put("getShop", "");
            orderLogMap.put("getTime", "");
            orderLogMap.put("returnShop", "");
            orderLogMap.put("returnTime", "");
            orderList.add(orderLogMap);
        }
        return orderList;
    }

    /**
     * 5.设值结算日志
     * @return
     */
    public static List<Map<String, Object>> setPayList(){
        List<Map<String, Object>> payList = new ArrayList<>();
        for (int i =0;i<10;i++) {
            Map<String, Object> payLogMap = new LinkedHashMap<>();
            payLogMap.put("orderId", "525657997327697085");
            payLogMap.put("passengerUserId", "27");
            payLogMap.put("driverUserId", "13");
            payLogMap.put("vehicleId", "12");
            payLogMap.put("recOrderTime", "2018-05-07 19:05:44");
            payLogMap.put("recOrderAdd", "长沙市岳麓区金星北路517号");
            payLogMap.put("recOrderLong", "112.931278");
            payLogMap.put("recOrderLat", "28.235271");
            payLogMap.put("aboardTime", "2018-05-07 19:07:44");
            payLogMap.put("departAdd", "长沙市岳麓区金星北路517号");
            payLogMap.put("startLong", "112.931278");
            payLogMap.put("startLat", "28.235271");
            payLogMap.put("debusTime", "2018-05-07 19:37:44");
            payLogMap.put("destinationAdd", "长沙市麓山城市建设投资有限责任公司");
            payLogMap.put("destinationLong", "112.929960");
            payLogMap.put("destinationLat", "28.224770");
            payLogMap.put("payOrderType", "微信支付");
            payLogMap.put("payAccount", "13017313120");
            payLogMap.put("payTime", "2018-05-07 19:40:57");
            payLogMap.put("money", "100");
            payList.add(payLogMap);
        }
        return payList;
    }
    /**
     * 6.设值轨迹日志
     * @return
     */
    public static List<Map<String, Object>> setPositionList(){
        List<Map<String, Object>> positionList = new ArrayList<>();
        for (int i =0;i<10;i++){
            Map<String, Object> positionLogMap = new LinkedHashMap<>();
                positionLogMap.put("orderId", "525657997327697085");
                positionLogMap.put("time", DateUtils.getUTCTime());
                try {
                    Thread.sleep(1000);
                }catch (Exception e){

                }
                positionLogMap.put("longItude", 112.931278+i);
                positionLogMap.put("latItude", 28.235271+i);
                positionList.add(positionLogMap);
        }

        return positionList;
    }

    /***
     * 乘客注册日志信息转换
     * @param list
     * @return
     */
    public static Map mapToMapForCustomer(List<Map<String, Object>> list){
        List<Map<String,Object>> dataList = new ArrayList<>();
        for (Map<String, Object> map : list) {
            Iterator<Map.Entry<String, Object>> iter = map.entrySet().iterator();
            List itemList = new ArrayList();
            //封装ITEM标签
            Map dataMap = new LinkedHashMap();
            while (iter.hasNext()) {
                Map.Entry<String, Object> next = iter.next();
                Map<String, Object> itemMap = null;
                if ("accountId".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B040003");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "用户ID");
                    itemMap.put("@eng", "ACCOUNT_ID");
                    itemMap.put("@rmk","用户ID");
                    itemList.add(itemMap);
                }
                if ("username".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B040002");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "用户名");
                    itemMap.put("@eng", "USERNAME");
                    itemMap.put("@rmk","用户名");
                    itemList.add(itemMap);
                }
                if ("accountType".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B040001");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "合作账号类型");
                    itemMap.put("@eng", "ACCOUNT_TYPE");
                    itemMap.put("@rmk","合作账号类型(手机)");
                    itemList.add(itemMap);
                }
                if ("account".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B040009");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "合作账号");
                    itemMap.put("@eng", "REG_ACCOUNT");
                    itemMap.put("@rmk","合作账号(手机号)");
                    itemList.add(itemMap);
                }
                if ("telephone".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B020005");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "认证手机号");
                    itemMap.put("@eng", "MOBILE_PHONE");
                    itemMap.put("@rmk","认证手机号");
                    itemList.add(itemMap);
                }
                if ("certifiType".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B030004");
                    itemMap.put("@val", "");
                    itemMap.put("@chn", "有效证件类型");
                    itemMap.put("@eng", "CERTIFICATE_TYPE");
                    itemMap.put("@rmk","有效证件类型(身份证)");
                    itemList.add(itemMap);
                }
                if ("certifiCode".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B030005");
                    itemMap.put("@val", "");
                    itemMap.put("@chn", "有效证件号码");
                    itemMap.put("@eng", "CERTIFICATE_CODE");
                    itemMap.put("@rmk","有效证件号码(身份证号)");
                    itemList.add(itemMap);
                }
                if ("ip".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "F020001");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "注册IP");
                    itemMap.put("@eng", "IP_ADDRESS");
                    itemMap.put("@rmk","注册IP");
                    itemList.add(itemMap);
                }
                if ("port".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "F020003");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "注册端口");
                    itemMap.put("@eng", "PORT");
                    itemMap.put("@rmk","注册端口");
                    itemList.add(itemMap);
                }
                if ("mac".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "C040002");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "注册MAC");
                    itemMap.put("@eng", "MAC_ADDRESS");
                    itemMap.put("@rmk","注册MAC");
                    itemList.add(itemMap);
                }
                if ("imei".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "C050001");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "注册IMEI");
                    itemMap.put("@eng", "IMEI");
                    itemMap.put("@rmk","注册IMEI");
                    itemList.add(itemMap);
                }
                if ("imsi".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B020007");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "注册IMSI");
                    itemMap.put("@eng", "IMSI");
                    itemMap.put("@rmk","注册IMSI");
                    itemList.add(itemMap);
                }
                if ("userPhoto".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H140016");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "用户头像");
                    itemMap.put("@eng", "USER_PHOTO");
                    itemMap.put("@rmk","用户头像URL");
                    itemList.add(itemMap);
                }
                if ("payAccountType".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B040010");
                    itemMap.put("@val", "");
                    itemMap.put("@chn", "绑定的支付帐号类型");
                    itemMap.put("@eng", "PAY_ACCOUNT_TYPE");
                    itemMap.put("@rmk","微信/支付宝");
                    itemList.add(itemMap);
                }
                if ("payAccount".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B040011");
                    itemMap.put("@val", "");
                    itemMap.put("@chn", "绑定的支付帐号");
                    itemMap.put("@eng", "PAY_ACCOUNT");
                    itemMap.put("@rmk","微信/支付宝");
                    itemList.add(itemMap);
                }
                if ("city".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B030002");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "注册城市");
                    itemMap.put("@eng", "CITY");
                    itemMap.put("@rmk", "注册城市");
                    itemList.add(itemMap);
                }
                if ("regisTime".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "G020026");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "注册时间");
                    itemMap.put("@eng", "REGIS_TIME");
                    itemMap.put("@rmk", "注册时间");
                    itemList.add(itemMap);
                }
                if ("lastTime".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B050014");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "最后更新时间");
                    itemMap.put("@eng", "LAST_TIME");
                    itemMap.put("@rmk", "最后更新时间");
                    itemList.add(itemMap);
                }
                //封装DATA标签
                dataMap.put("ITEM", itemList);
            }
            dataList.add(dataMap);
        }
        //封装DATASET标签
        Map dataSetMap = new LinkedHashMap();
        dataSetMap.put("@name","WA_BASIC_0009_05");
        dataSetMap.put("@rmk","乘客注册信息");
        dataSetMap.put("DATA",dataList);
        //返回DATASET
        return dataSetMap;
    }

    /***
     * 专车/快车/顺风车注册日志信息转换
     * @param list
     * @return
     */
    public static Map mapToMapForDriver1(List<Map<String, Object>> list){
        List<Map<String,Object>> dataList = new ArrayList<>();
        for (Map<String, Object> map : list) {
            Iterator<Map.Entry<String, Object>> iter = map.entrySet().iterator();
            List itemList = new ArrayList();
            //封装ITEM标签
            Map dataMap = new LinkedHashMap();
            while (iter.hasNext()) {
                Map.Entry<String, Object> next = iter.next();
                Map<String, Object> itemMap = null;
                if ("accountId".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B040003");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "用户ID");
                    itemMap.put("@eng", "ACCOUNT_ID");
                    itemMap.put("@rmk", "用户ID");
                    itemList.add(itemMap);
                }
                if ("username".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B040002");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "用户名");
                    itemMap.put("@eng", "ACCOUNT");
                    itemMap.put("@rmk", "用户名");
                    itemList.add(itemMap);
                }
                if ("accountType".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B040001");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "合作账号类型");
                    itemMap.put("@eng", "ACCOUNT_TYPE");
                    itemMap.put("@rmk", "合作账号类型(手机)");
                    itemList.add(itemMap);
                }
                if ("account".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B040009");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "合作账号");
                    itemMap.put("@eng", "REG_ACCOUNT");
                    itemMap.put("@rmk", "合作账号(手机号)");
                    itemList.add(itemMap);
                }
                if ("telephone".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B020005");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "认证手机号");
                    itemMap.put("@eng", "MOBILE_PHONE");
                    itemMap.put("@rmk", "认证手机号");
                    itemList.add(itemMap);
                }
                if ("certifiType".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B030004");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "有效证件类型");
                    itemMap.put("@eng", "CERTIFICATE_TYPE");
                    itemMap.put("@rmk", "有效证件类型(身份证)");
                    itemList.add(itemMap);
                }
                if ("certifiCode".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B030005");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "有效证件号码");
                    itemMap.put("@eng", "CERTIFICATE_CODE");
                    itemMap.put("@rmk", "有效证件号码(身份证号)");
                    itemList.add(itemMap);
                }
                if ("ip".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "F020001");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "注册IP");
                    itemMap.put("@eng", "IP_ADDRESS");
                    itemMap.put("@rmk", "注册IP");
                    itemList.add(itemMap);
                }
                if ("port".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "F020003");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "注册端口");
                    itemMap.put("@eng", "PORT");
                    itemMap.put("@rmk", "注册端口");
                    itemList.add(itemMap);
                }
                if ("mac".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "C040002");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "注册MAC");
                    itemMap.put("@eng", "MAC_ADDRESS");
                    itemMap.put("@rmk", "注册MAC");
                    itemList.add(itemMap);
                }
                if ("imei".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "C050001");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "注册IMEI");
                    itemMap.put("@eng", "IMEI");
                    itemMap.put("@rmk", "注册IMEI");
                    itemList.add(itemMap);
                }
                if ("imsi".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B020007");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "注册IMSI");
                    itemMap.put("@eng", "IMSI");
                    itemMap.put("@rmk", "注册IMSI");
                    itemList.add(itemMap);
                }
                if ("userPhoto".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H140016");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "用户头像");
                    itemMap.put("@eng", "USER_PHOTO");
                    itemMap.put("@rmk", "用户头像(URL)");
                    itemList.add(itemMap);
                }
                if ("payAccountType".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B040010");
                    itemMap.put("@val", "");
                    itemMap.put("@chn", "绑定的收款帐号类型");
                    itemMap.put("@eng", "PAY_ACCOUNT_TYPE");
                    itemMap.put("@rmk", "直营不涉及");
                    itemList.add(itemMap);
                }
                if ("payAccount".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B040011");
                    itemMap.put("@val", "");
                    itemMap.put("@chn", "绑定的收款帐号");
                    itemMap.put("@eng", "PAY_ACCOUNT");
                    itemMap.put("@rmk", "直营不涉及");
                    itemList.add(itemMap);
                }
                if ("vehicleId".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "C030009");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "车辆ID");
                    itemMap.put("@eng", "VEHICLE_ID");
                    itemMap.put("@rmk", "车辆ID");
                    itemList.add(itemMap);
                }
                if ("vehicleCode".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "C030002");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "车牌号");
                    itemMap.put("@eng", "VEHICLE_CODE");
                    itemMap.put("@rmk", "车牌号");
                    itemList.add(itemMap);
                }
                if ("operCertificate".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B030904");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "营运证件号码");
                    itemMap.put("@eng", "OPERATION_CERTIFICATE");
                    itemMap.put("@rmk", "营运证件号码");
                    itemList.add(itemMap);
                }
                if ("carColor".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "C010004");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "车辆颜色");
                    itemMap.put("@eng", "CAR_COLOR");
                    itemMap.put("@rmk", "车辆颜色");
                    itemList.add(itemMap);
                }
                if ("carBrand".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "C010002");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "车辆品牌");
                    itemMap.put("@eng", "CAR_BRAND");
                    itemMap.put("@rmk", "车辆品牌");
                    itemList.add(itemMap);
                }
                if ("carVersion".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "C010003");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "车辆型号");
                    itemMap.put("@eng", "CAR_VERSION");
                    itemMap.put("@rmk", "车辆型号");
                    itemList.add(itemMap);
                }
                if ("policyPhoto".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "C030012");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "车辆保险单图片");
                    itemMap.put("@eng", "POLICY_PHOTO");
                    itemMap.put("@rmk", "车辆保险单图片");
                    itemList.add(itemMap);
                }
                if ("company".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "E010002");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "车辆所属公司");
                    itemMap.put("@eng", "COMPANY");
                    itemMap.put("@rmk", "车辆所属公司");
                    itemList.add(itemMap);
                }
                if ("city".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B030002");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "注册城市");
                    itemMap.put("@eng", "CITY");
                    itemMap.put("@rmk", "注册城市");
                    itemList.add(itemMap);
                }
                if ("regisTime".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "G020026");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "注册时间");
                    itemMap.put("@eng", "REGIS_TIME");
                    itemMap.put("@rmk", "注册时间");
                    itemList.add(itemMap);
                }
                if ("lastTime".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B050014");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "最后更新时间");
                    itemMap.put("@eng", "LAST_TIME");
                    itemMap.put("@rmk", "最后更新时间");
                    itemList.add(itemMap);
                }
                //封装DATA标签
                dataMap.put("ITEM", itemList);
            }
            dataList.add(dataMap);
        }
        //封装DATASET标签
        Map dataSetMap = new LinkedHashMap();
        dataSetMap.put("@name","WA_BASIC_0009_06");
        dataSetMap.put("@rmk","网约车司机信息");
        dataSetMap.put("DATA",dataList);
        //返回DATASET
        return dataSetMap;
    }

    /***
     * 出租车注册日志信息转换
     * @return
     */
    public static Map mapToMapForDriver2(){
        //封装DATASET标签
        Map dataSetMap = new LinkedHashMap();
        dataSetMap.put("@name","WA_BASIC_0009_07");
        dataSetMap.put("@rmk","出租车注册日志信息(此项业务未开展)");
        return dataSetMap;
    }

    /***
     * 代驾注册日志信息转换
     * @return
     */
    public static Map mapToMapForDriver3(){
        //封装DATASET标签
        Map dataSetMap = new LinkedHashMap();
        dataSetMap.put("@name","WA_BASIC_0009_08");
        dataSetMap.put("@rmk","代驾注册日志信息(此项业务未开展)");
        return dataSetMap;
    }

    /***
     * 登录日志信息转换
     * @param list
     * @return
     */
    public static Map mapToMapForLogin(List<Map<String, Object>> list){
        List<Map<String,Object>> dataList = new ArrayList<>();
        for (Map<String, Object> map : list) {
            Iterator<Map.Entry<String, Object>> iter = map.entrySet().iterator();
            List itemList = new ArrayList();
            //封装ITEM标签
            Map dataMap = new LinkedHashMap();
            while (iter.hasNext()) {
                Map.Entry<String, Object> next = iter.next();
                Map<String, Object> itemMap = null;
                if ("accountId".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B040003");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "用户ID");
                    itemMap.put("@eng", "ACCOUNT_ID");
                    itemMap.put("@rmk", "用户ID");
                    itemList.add(itemMap);
                }
                if ("username".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B040002");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "用户名");
                    itemMap.put("@eng", "ACCOUNT");
                    itemMap.put("@rmk", "用户名");
                    itemList.add(itemMap);
                }
                if ("srcIp".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "F020004");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "登录IP");
                    itemMap.put("@eng", "SRC_IP");
                    itemMap.put("@rmk", "登录IP");
                    itemList.add(itemMap);
                }
                if ("srcPort".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "F020006");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "登录端口号");
                    itemMap.put("@eng", "SRC_PORT");
                    itemMap.put("@rmk", "登录端口号");
                    itemList.add(itemMap);
                }
                if ("mac".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "C040002");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "登录MAC");
                    itemMap.put("@eng", "MAC");
                    itemMap.put("@rmk", "登录MAC");
                    itemList.add(itemMap);
                }
                if ("imei".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "C050001");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "登录IMEI");
                    itemMap.put("@eng", "IMEI_ESN_MEID");
                    itemMap.put("@rmk", "登录IMEI");
                    itemList.add(itemMap);
                }
                if ("imsi".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B020007");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "登录IMSI");
                    itemMap.put("@eng", "IMSI");
                    itemMap.put("@rmk", "登录IMSI");
                    itemList.add(itemMap);
                }
                if ("logType".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H010003");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "登录类型");
                    itemMap.put("@eng", "LOG_TYPE");
                    itemMap.put("@rmk", "登录类型");
                    itemList.add(itemMap);
                }
                if ("logTime".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H090006");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "登录时间");
                    itemMap.put("@eng", "LOGIN_TIME");
                    itemMap.put("@rmk", "登录时间");
                    itemList.add(itemMap);
                }
                if ("long".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "F010001");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "经度");
                    itemMap.put("@eng", "LONGITUDE");
                    itemMap.put("@rmk", "经度");
                    itemList.add(itemMap);
                }
                if ("lat".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "F010002");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "纬度");
                    itemMap.put("@eng", "LATITUDE");
                    itemMap.put("@rmk", "纬度");
                    itemList.add(itemMap);
                }
                //封装DATA标签
                dataMap.put("ITEM", itemList);
            }
            dataList.add(dataMap);
        }
        //封装DATASET标签
        Map dataSetMap = new LinkedHashMap();
        dataSetMap.put("@name","WA_SOURCE_0029");
        dataSetMap.put("@rmk","登录日志信息");
        dataSetMap.put("DATA",dataList);
        //返回DATASET
        return dataSetMap;
    }

    /***
     * 订单日志信息转换
     * @param list
     * @return
     */
    public static Map mapToMapForOrder(List<Map<String, Object>> list){
        List<Map<String,Object>> dataList = new ArrayList<>();
        for (Map<String, Object> map : list) {
            Iterator<Map.Entry<String, Object>> iter = map.entrySet().iterator();
            List itemList = new ArrayList();
            //封装ITEM标签
            Map dataMap = new LinkedHashMap();
            while (iter.hasNext()) {
                Map.Entry<String, Object> next = iter.next();
                Map<String, Object> itemMap = null;
                if ("accountId".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B040003");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "用户ID");
                    itemMap.put("@eng", "ACCOUNT_ID");
                    itemMap.put("@rmk", "用户ID");
                    itemList.add(itemMap);
                }
                if ("orderText".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230001");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "订单内容(文本)");
                    itemMap.put("@eng", "ORDER_TEXT_CONTENT");
                    itemMap.put("@rmk", "订单内容(文本)");
                    itemList.add(itemMap);
                }
                if ("orderMedia".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230002");
                    itemMap.put("@val", "");
                    itemMap.put("@chn", "订单内容(语音)");
                    itemMap.put("@eng", "ORDER_MULTIMEDIA_CONTENT");
                    itemMap.put("@rmk", "订单内容(语音)未涉及");
                    itemList.add(itemMap);
                }
                if ("orderTime".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230003");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "下单时间");
                    itemMap.put("@eng", "PLACE_ORDER_TIME");
                    itemMap.put("@rmk", "下单时间");
                    itemList.add(itemMap);
                }
                if ("orderPhone".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B020005");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "下单手机号");
                    itemMap.put("@eng", "MOBILE_PHONE");
                    itemMap.put("@rmk", "下单手机号");
                    itemList.add(itemMap);
                }
                if ("orderPort".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "F020006");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "下单端口号");
                    itemMap.put("@eng", "SRC_PORT");
                    itemMap.put("@rmk", "下单端口号");
                    itemList.add(itemMap);
                }
                if ("orderIp".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "F020004");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "下单IP地址");
                    itemMap.put("@eng", "SRC_IP");
                    itemMap.put("@rmk", "下单IP地址");
                    itemList.add(itemMap);
                }
                if ("orderMac".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "C040002");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "下单MAC");
                    itemMap.put("@eng", "MAC");
                    itemMap.put("@rmk", "下单MAC");
                    itemList.add(itemMap);
                }
                if ("orderImei".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "C050001");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "下单IMEI");
                    itemMap.put("@eng", "IMEI");
                    itemMap.put("@rmk", "下单IMEI");
                    itemList.add(itemMap);
                }
                if ("orderImsi".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B020007");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "下单IMSI");
                    itemMap.put("@eng", "IMSI");
                    itemMap.put("@rmk", "下单IMSI");
                    itemList.add(itemMap);
                }
                if ("orderAdd".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230004");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "下单地址");
                    itemMap.put("@eng", "PLACE_ORDER_ADDRESS");
                    itemMap.put("@rmk", "下单地址");
                    itemList.add(itemMap);
                }
                if ("orderLong".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "F010001");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "下单经度");
                    itemMap.put("@eng", "PLACE_ORDER_LONGITUDE");
                    itemMap.put("@rmk", "下单经度");
                    itemList.add(itemMap);
                }
                if ("orderLat".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "F010002");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "下单纬度");
                    itemMap.put("@eng", "PLACE_ORDER_LATITUDE");
                    itemMap.put("@rmk", "下单纬度");
                    itemList.add(itemMap);
                }
                if ("vehicleType".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230007");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "租约车类型");
                    itemMap.put("@eng", "VEHICLE_SERVICE_TYPE");
                    itemMap.put("@rmk", "租约车类型");
                    itemList.add(itemMap);
                }
                if ("aboardTime".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230009");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "预约上车时间");
                    itemMap.put("@eng", "ADVANCE_ABOARD_TIME");
                    itemMap.put("@rmk", "预约上车时间");
                    itemList.add(itemMap);
                }
                if ("aboardAdd".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230010");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "预约上车地址");
                    itemMap.put("@eng", "ADVANCE_ABOARD_ADDRESS");
                    itemMap.put("@rmk", "预约上车地址");
                    itemList.add(itemMap);
                }
                if ("aboardLong".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230011");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "预约上车经度");
                    itemMap.put("@eng", "ADVANCE_ABOARD_LONGITUDE");
                    itemMap.put("@rmk", "预约上车经度");
                    itemList.add(itemMap);
                }
                if ("aboardLat".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230012");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "预约上车纬度");
                    itemMap.put("@eng", "ADVANCE_ABOARD_LATITUDE");
                    itemMap.put("@rmk", "预约上车纬度");
                    itemList.add(itemMap);
                }
                if ("debusAdd".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230013");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "预约下车地址");
                    itemMap.put("@eng", "ADVANCE_DEBUS_ADDRESS");
                    itemMap.put("@rmk", "预约下车地址");
                    itemList.add(itemMap);
                }
                if ("debusLong".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230014");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "预约下车经度");
                    itemMap.put("@eng", "ADVANCE_DEBUS_LONGITUDE");
                    itemMap.put("@rmk", "预约下车经度");
                    itemList.add(itemMap);
                }
                if ("debusLat".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230015");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "预约下车纬度");
                    itemMap.put("@eng", "ADVANCE_DEBUS_LATITUDE");
                    itemMap.put("@rmk", "预约下车纬度");
                    itemList.add(itemMap);
                }
                if ("getCity".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230016");
                    itemMap.put("@val", "");
                    itemMap.put("@chn", "取车城市");
                    itemMap.put("@eng", "ADVANCE_GET_CITY");
                    itemMap.put("@rmk", "取车城市(未涉及)");
                    itemList.add(itemMap);
                }
                if ("getShop".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230017");
                    itemMap.put("@val", "");
                    itemMap.put("@chn", "取车门店");
                    itemMap.put("@eng", "ADVANCE_GET_SHOP");
                    itemList.add(itemMap);
                    itemMap.put("@rmk", "取车门店(未涉及)");
                }
                if ("getTime".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230018");
                    itemMap.put("@val", "");
                    itemMap.put("@chn", "取车时间");
                    itemMap.put("@eng", "ADVANCE_GET_TIME");
                    itemMap.put("@rmk", "取车时间(未涉及)");
                    itemList.add(itemMap);
                }
                if ("returnShop".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230019");
                    itemMap.put("@val", "");
                    itemMap.put("@chn", "预还车门店");
                    itemMap.put("@eng", "ADVANCE_RETURN_SHOP");
                    itemMap.put("@rmk", "预还车门店(未涉及)");
                    itemList.add(itemMap);
                }
                if ("returnTime".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230020");
                    itemMap.put("@val", "");
                    itemMap.put("@chn", "预还车时间");
                    itemMap.put("@eng", "ADVANCE_RETURN_TIME");
                    itemMap.put("@rmk", "预还车时间(未涉及)");
                    itemList.add(itemMap);
                }
                //封装DATA标签
                dataMap.put("ITEM", itemList);
            }
            dataList.add(dataMap);
        }
        //封装DATASET标签
        Map dataSetMap = new LinkedHashMap();
        dataSetMap.put("@name","WA_SOURCE_0047");
        dataSetMap.put("@rmk","订单日志信息");
        dataSetMap.put("DATA",dataList);
        //返回DATASET
        return dataSetMap;
    }

    /***
     * 结算日志信息转换
     * @param list
     * @return
     */
    public static Map mapToMapForPay(List<Map<String, Object>> list){
        List<Map<String,Object>> dataList = new ArrayList<>();
        for (Map<String, Object> map : list) {
            Iterator<Map.Entry<String, Object>> iter = map.entrySet().iterator();
            List itemList = new ArrayList();
            //封装ITEM标签
            Map dataMap = new LinkedHashMap();
            while (iter.hasNext()) {
                Map.Entry<String, Object> next = iter.next();
                Map<String, Object> itemMap = null;
                if ("orderId".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H090001");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "订单ID");
                    itemMap.put("@eng", "ORDER_NUM");
                    itemMap.put("@rmk", "订单ID");
                    itemList.add(itemMap);
                }
                if ("passengerUserId".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230022");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "乘客用户ID");
                    itemMap.put("@eng", "PASSENGER_USER_ID");
                    itemMap.put("@rmk", "乘客用户ID");
                    itemList.add(itemMap);
                }
                if ("driverUserId".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230021");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "司机用户ID");
                    itemMap.put("@eng", "DRIVER_USER_ID");
                    itemMap.put("@rmk", "司机用户ID");
                    itemList.add(itemMap);
                }
                if ("vehicleId".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "C030009");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "车辆ID");
                    itemMap.put("@eng", "VEHICLE_ID");
                    itemMap.put("@rmk", "车辆ID");
                    itemList.add(itemMap);
                }
                if ("recOrderTime".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230023");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "接单时间");
                    itemMap.put("@eng", "RECEIVE_ORDER_TIME");
                    itemMap.put("@rmk", "接单时间");
                    itemList.add(itemMap);
                }
                if ("recOrderAdd".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230024");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "接单地址");
                    itemMap.put("@eng", "RECEIVE_ORDER_ADDRESS");
                    itemMap.put("@rmk", "接单地址");
                    itemList.add(itemMap);
                }
                if ("recOrderLong".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230025");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "接单经度");
                    itemMap.put("@eng", "RECEIVE_ORDER_LONGITUDE");
                    itemMap.put("@rmk", "接单经度");
                    itemList.add(itemMap);
                }
                if ("recOrderLat".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230026");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "接单纬度");
                    itemMap.put("@eng", "RECEIVE_ORDER_LATITUDE");
                    itemMap.put("@rmk", "接单纬度");
                    itemList.add(itemMap);
                }
                if ("aboardTime".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230027");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "上车时间");
                    itemMap.put("@eng", "ABOARD_TIME");
                    itemMap.put("@rmk", "上车时间");
                    itemList.add(itemMap);
                }
                if ("departAdd".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "F010014");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "上车地址");
                    itemMap.put("@eng", "DEPART_ADDRESS");
                    itemMap.put("@rmk", "上车地址");
                    itemList.add(itemMap);
                }
                if ("startLong".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "F010010");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "上车经度");
                    itemMap.put("@eng", "START_LONGITUDE");
                    itemMap.put("@rmk", "上车经度");
                    itemList.add(itemMap);
                }
                if ("startLat".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "F010011");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "上车纬度");
                    itemMap.put("@eng", "START_LATITUDE");
                    itemMap.put("@rmk", "上车纬度");
                    itemList.add(itemMap);
                }
                if ("debusTime".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H230028");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "下车时间");
                    itemMap.put("@eng", "DEBUS_TIME");
                    itemMap.put("@rmk", "下车时间");
                    itemList.add(itemMap);
                }
                if ("destinationAdd".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "F010015");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "下车地址");
                    itemMap.put("@eng", "DESTINATION_ADDRESS");
                    itemMap.put("@rmk", "下车地址");
                    itemList.add(itemMap);
                }
                if ("destinationLong".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "F010012");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "下车经度");
                    itemMap.put("@eng", "DESTINATION_LONGITUDE");
                    itemMap.put("@rmk", "下车经度");
                    itemList.add(itemMap);
                }
                if ("destinationLat".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "F010013");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "下车纬度");
                    itemMap.put("@eng", "DESTINATION_LATITUDE");
                    itemMap.put("@rmk", "下车纬度");
                    itemList.add(itemMap);
                }
                if ("payOrderType".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B040010");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "支付类型");
                    itemMap.put("@eng", "PAY_ORDER_TYPE");
                    itemMap.put("@rmk", "支付类型");
                    itemList.add(itemMap);
                }
                if ("payAccount".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "B040011");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "支付帐号");
                    itemMap.put("@eng", "PAY_ACCOUNT");
                    itemMap.put("@rmk", "支付帐号");
                    itemList.add(itemMap);
                }
                if ("payTime".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H090004");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "支付时间");
                    itemMap.put("@eng", "PAYTIME");
                    itemMap.put("@rmk", "支付时间");
                    itemList.add(itemMap);
                }
                if ("money".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "C010007");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "交易金额");
                    itemMap.put("@eng", "MONEY");
                    itemMap.put("@rmk", "单位：元");
                    itemMap.put("@rmk", "交易金额");
                    itemList.add(itemMap);
                }
                //封装DATA标签
                dataMap.put("ITEM", itemList);
            }
            dataList.add(dataMap);
        }
        //封装DATASET标签
        Map dataSetMap = new LinkedHashMap();
        dataSetMap.put("@name","WA_SOURCE_0031");
        dataSetMap.put("@rmk","结算日志信息");
        dataSetMap.put("DATA",dataList);
        //返回DATASET
        return dataSetMap;
    }

    /***
     * 快递日志信息转换
     * @return
     */
    public static Map mapToMapForDelivery(){
        //封装DATASET标签
        Map dataSetMap = new LinkedHashMap();
        dataSetMap.put("@name","WA_SOURCE_0027");
        dataSetMap.put("@rmk","快递日志信息(此项业务未开展)");
        return dataSetMap;
    }

    /***
     * 聊天日志信息转换
     * @return
     */
    public static Map mapToMapForIM(){
        //封装DATASET标签
        Map dataSetMap = new LinkedHashMap();
        dataSetMap.put("@name","WA_SOURCE_0005");
        dataSetMap.put("@rmk","聊天日志信息(此项业务未开展)");
        return dataSetMap;
    }

    /***
     * 行驶轨迹日志信息转换
     * @param list
     * @return
     */
    public static Map mapToMapForDriving(List<Map<String, Object>> list){
        Map returnMap = new LinkedHashMap();
        List<Map<String,Object>> dataList = new ArrayList<>();
        for (Map<String, Object> map : list) {
            Iterator<Map.Entry<String, Object>> iter = map.entrySet().iterator();
            List itemList = new ArrayList();
            //封装ITEM标签
            Map dataMap = new LinkedHashMap();
            while (iter.hasNext()) {
                Map.Entry<String, Object> next = iter.next();
                Map<String, Object> itemMap = null;
                if ("orderId".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H090001");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "订单ID");
                    itemMap.put("@eng", "ORDER_NUM");
                    itemMap.put("@rmk", "订单ID");
                    itemList.add(itemMap);
                }
                if ("time".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "H090003");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "时间");
                    itemMap.put("@eng", "TIME");
                    itemMap.put("@rmk", "时间");
                    itemList.add(itemMap);
                }
                if ("longItude".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "F010001");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "经度");
                    itemMap.put("@eng", "LONGITUDE");
                    itemMap.put("@rmk", "经度");
                    itemList.add(itemMap);
                }
                if ("latItude".equals(next.getKey())) {
                    itemMap = new LinkedHashMap<>();
                    itemMap.put("@key", "F010002");
                    itemMap.put("@val", next.getValue());
                    itemMap.put("@chn", "纬度");
                    itemMap.put("@eng", "LATITUDE");
                    itemMap.put("@rmk", "纬度");
                    itemList.add(itemMap);
                }
                //封装DATA标签
                dataMap.put("ITEM", itemList);
            }
            dataList.add(dataMap);
        }
        //封装DATASET标签
        Map dataSetMap = new LinkedHashMap();
        dataSetMap.put("@name","WA_SOURCE_0027");
        dataSetMap.put("@rmk","行驶轨迹");
        dataSetMap.put("DATA",dataList);
        //返回DATASET
        return dataSetMap;
    }

    /***
     * 生成xml文件
     * @param pathName
     * @param document
     * @throws IOException
     */
    public static void createXmlFile(String pathName, Document document) throws IOException {
        File file = new File(pathName);

        XMLWriter writer=new XMLWriter(new FileOutputStream(file),OutputFormat.createPrettyPrint());
        //字符是否转义,默认true
        writer.setEscapeText(false);
        writer.write(document);
        writer.close();
    }

    /**
     * xml转map 不带属性
     * @param xmlStr
     * @param needRootKey 是否需要在返回的map里加根节点键
     * @return
     * @throws DocumentException
     */
    public static Map xml2map(String xmlStr, boolean needRootKey) throws DocumentException {
        Document doc = DocumentHelper.parseText(xmlStr);
        Element root = doc.getRootElement();
        Map<String, Object> map = (Map<String, Object>) xml2map(root);
        if(root.elements().size()==0 && root.attributes().size()==0){
            return map;
        }
        if(needRootKey){
            //在返回的map里加根节点键（如果需要）
            Map<String, Object> rootMap = new HashMap<String, Object>();
            rootMap.put(root.getName(), map);
            return rootMap;
        }
        return map;
    }

    /**
     * xml转map 带属性
     * @param xmlStr
     * @param needRootKey 是否需要在返回的map里加根节点键
     * @return
     * @throws DocumentException
     */
    public static Map xml2mapWithAttr(String xmlStr, boolean needRootKey) throws DocumentException {
        Document doc = DocumentHelper.parseText(xmlStr);
        Element root = doc.getRootElement();
        Map<String, Object> map = (Map<String, Object>) xml2mapWithAttr(root);
        if(root.elements().size()==0 && root.attributes().size()==0){
            //根节点只有一个文本内容
            return map;
        }
        if(needRootKey){
            //在返回的map里加根节点键（如果需要）
            Map<String, Object> rootMap = new HashMap<String, Object>();
            rootMap.put(root.getName(), map);
            return rootMap;
        }
        return map;
    }

    /**
     * xml转map 不带属性
     * @param e
     * @return
     */
    private static Map xml2map(Element e) {
        Map map = new LinkedHashMap();
        List list = e.elements();
        if (list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                Element iter = (Element) list.get(i);
                List mapList = new ArrayList();

                if (iter.elements().size() > 0) {
                    Map m = xml2map(iter);
                    if (map.get(iter.getName()) != null) {
                        Object obj = map.get(iter.getName());
                        if (!(obj instanceof List)) {
                            mapList = new ArrayList();
                            mapList.add(obj);
                            mapList.add(m);
                        }
                        if (obj instanceof List) {
                            mapList = (List) obj;
                            mapList.add(m);
                        }
                        map.put(iter.getName(), mapList);
                    } else {
                        map.put(iter.getName(), m);
                    }
                } else {
                    if (map.get(iter.getName()) != null) {
                        Object obj = map.get(iter.getName());
                        if (!(obj instanceof List)) {
                            mapList = new ArrayList();
                            mapList.add(obj);
                            mapList.add(iter.getText());
                        }
                        if (obj instanceof List) {
                            mapList = (List) obj;
                            mapList.add(iter.getText());
                        }
                        map.put(iter.getName(), mapList);
                    } else {
                        map.put(iter.getName(), iter.getText());
                    }
                }
            }
        } else {
            map.put(e.getName(), e.getText());
        }
        return map;
    }

    /**
     * xml转map 带属性
     * @param element
     * @return
     */
    private static Map xml2mapWithAttr(Element element) {
        Map<String, Object> map = new LinkedHashMap<String, Object>();

        List<Element> list = element.elements();
        // 当前节点的所有属性的list
        List<Attribute> listAttr0 = element.attributes();
        for (Attribute attr : listAttr0) {
            map.put("@" + attr.getName(), attr.getValue());
        }
        if (list.size() > 0) {

            for (int i = 0; i < list.size(); i++) {
                Element iter = list.get(i);
                List mapList = new ArrayList();

                if (iter.elements().size() > 0) {
                    Map m = xml2mapWithAttr(iter);
                    if (map.get(iter.getName()) != null) {
                        Object obj = map.get(iter.getName());
                        if (!(obj instanceof List)) {
                            mapList = new ArrayList();
                            mapList.add(obj);
                            mapList.add(m);
                        }
                        if (obj instanceof List) {
                            mapList = (List) obj;
                            mapList.add(m);
                        }
                        map.put(iter.getName(), mapList);
                    } else {
                        map.put(iter.getName(), m);
                    }
                } else {
                    // 当前节点的所有属性的list
                    List<Attribute> listAttr = iter.attributes();
                    Map<String, Object> attrMap = null;
                    boolean hasAttributes = false;
                    if (listAttr.size() > 0) {
                        hasAttributes = true;
                        attrMap = new LinkedHashMap<String, Object>();
                        for (Attribute attr : listAttr) {
                            attrMap.put("@" + attr.getName(), attr.getValue());
                        }
                    }

                    if (map.get(iter.getName()) != null) {
                        Object obj = map.get(iter.getName());
                        if (!(obj instanceof List)) {
                            mapList = new ArrayList();
                            mapList.add(obj);
                            // mapList.add(iter.getText());
                            if (hasAttributes) {
                                attrMap.put("#text", iter.getText());
                                mapList.add(attrMap);
                            } else {
                                mapList.add(iter.getText());
                            }
                        }
                        if (obj instanceof List) {
                            mapList = (List) obj;
                            // mapList.add(iter.getText());
                            if (hasAttributes) {
                                attrMap.put("#text", iter.getText());
                                mapList.add(attrMap);
                            } else {
                                mapList.add(iter.getText());
                            }
                        }
                        map.put(iter.getName(), mapList);
                    } else {
                        // map.put(iter.getName(), iter.getText());
                        if (hasAttributes) {
                            attrMap.put("#text", iter.getText());
                            map.put(iter.getName(), attrMap);
                        } else {
                            map.put(iter.getName(), iter.getText());
                        }
                    }
                }
            }
        } else {
            // 根节点的
            if (listAttr0.size() > 0) {
                map.put("#text", element.getText());
            } else {
                map.put(element.getName(), element.getText());
            }
        }
        return map;
    }

    /**
     * map转xml map中没有根节点的键
     * @param map
     * @param rootName
     * @throws DocumentException
     * @throws IOException
     */
    public static Document map2xml(Map<String, Object> map, String rootName) throws DocumentException, IOException  {
        Document doc = DocumentHelper.createDocument();
        Element root = DocumentHelper.createElement(rootName);
        doc.add(root);
        map2xml(map, root);
        //System.out.println(doc.asXML());
        //System.out.println(formatXml(doc));
        return doc;
    }

    /**
     * map转xml map中含有根节点的键
     * @param map
     * @throws DocumentException
     * @throws IOException
     */
    public static Document map2xml(Map<String, Object> map) throws DocumentException, IOException  {
        Iterator<Map.Entry<String, Object>> entries = map.entrySet().iterator();
        if(entries.hasNext()){
            //获取第一个键创建根节点
            Map.Entry<String, Object> entry = entries.next();
            Document doc = DocumentHelper.createDocument();
            Element root = DocumentHelper.createElement(entry.getKey());
            doc.add(root);
            map2xml((Map)entry.getValue(), root);
            //System.out.println(doc.asXML());
            //System.out.println(formatXml(doc));
            return doc;
        }
        return null;
    }

    /**
     * map转xml
     * @param map
     * @param body xml元素
     * @return
     */
    private static Element map2xml(Map<String, Object> map, Element body) {
        Iterator<Map.Entry<String, Object>> entries = map.entrySet().iterator();
        while (entries.hasNext()) {
            Map.Entry<String, Object> entry = entries.next();
            String key = entry.getKey();
            Object value = entry.getValue();
            if(key.startsWith("@")){
                //属性
                body.addAttribute(key.substring(1, key.length()), value.toString());
            } else if("#text".equals(key)){
                //有属性时的文本
                body.setText(value.toString());
            } else {
                if(value instanceof List ){
                    List list = (List)value;
                    Object obj;
                    for(int i=0; i<list.size(); i++){
                        obj = list.get(i);
                        //list里是map或String，不会存在list里直接是list的，
                        if(obj instanceof Map){
                            Element subElement = body.addElement(key);
                            map2xml((Map)list.get(i), subElement);
                        } else {
                            body.addElement(key).setText((String)list.get(i));
                        }
                    }
                } else if(value instanceof Map ){
                    Element subElement = body.addElement(key);
                    map2xml((Map)value, subElement);
                } else {
                    body.addElement(key).setText(value.toString());
                }
            }
            //System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
        }
        return body;
    }

    /**
     * 格式化输出xml
     * @param xmlStr
     * @return
     * @throws DocumentException
     * @throws IOException
     */
    public static String formatXml(String xmlStr) throws DocumentException, IOException {
        Document document = DocumentHelper.parseText(xmlStr);
        return formatXml(document);
    }

    /**
     * 格式化输出xml
     * @param document
     * @return
     * @throws DocumentException
     * @throws IOException
     */
    public static String formatXml(Document document) throws DocumentException, IOException  {
        // 格式化输出格式
        OutputFormat format = OutputFormat.createPrettyPrint();
        //format.setEncoding("UTF-8");
        StringWriter writer = new StringWriter();
        // 格式化输出流
        XMLWriter xmlWriter = new XMLWriter(writer, format);
        // 将document写入到输出流
        xmlWriter.write(document);
        xmlWriter.close();
        return writer.toString();
    }

}
